/*****************************************************************************
 *
 * Copyright (c), 2004-2020,ShangHai Neotune Information Technology Co., Ltd.
 *
 * Module Name : auxfuncs.h
 *
 * Author :    sean
 *
 * Date :    2004-02-05
 *
 * Version :    1.00
 *
 * Description :    
 *
 * Other :    
 *
 * Data Structure List: <Main Data Structure>
 *
 * Modification History
 * ---------------------------------------------------------------------------
 *  1: Data :      2004-02-05
 *    Author :     sean
 *    Version :    V100R001M00
 *    Modification : creation
 *
*****************************************************************************/

#ifndef auxfuncs_inc
#define auxfuncs_inc

#ifdef __cplusplus
extern"C" {
#endif

#if (!defined(buildpkt_inc))
#include "buildpkt.h"
#endif

#if (!defined(auxmth_inc))
#include "auxmth.h"
#endif

#ifdef NEOSNET_STRUCT_ALIGN
#pragma align 1
#endif

/* A structure used for looking up all the pieces of a row create of an
 * SNMP packet. */
struct create_row {
  MIBLEAF_T *leaf;
  OCTET_T flags;
};

#ifdef NEOSNET_STRUCT_ALIGN
#pragma align 0
#endif

#define ROW_FLAG_NEEDED 0x01
#define ROW_FLAG_CALL_SET 0x02

/* various other housekeeping functions */
extern int ip_to_llist __((UINT_32_T ip,
                           INT_32_T *llist));

extern int ip_to_rlist __((UINT_32_T  ip,
                           OIDC_T    *rlist));

extern int llist_cmp __((INT_32_T *list1,
                         INT_32_T *list2,
                         int       len));

extern int oid_to_ip __((int        tcount,
                         OIDC_T    *tlist,
                         UINT_32_T *addr));

extern int oidcmp __((int     tcount_1,
                      OIDC_T *tlist_1,
                      int     tcount_2,
                      OIDC_T *tlist_2));

extern int oidcmp2 __((int     tcount_1,
                       OIDC_T *tlist_1,
                       int     tcount_2,
                       OIDC_T *tlist_2));

extern int oidorder __((OIDC_T *idp1,
                        OIDC_T *idp2,
                        int      n));

extern int scan_vb_for_locator __((SNMP_PKT_T * pktp,
                                   int          vb_index,
                                   UINT_16_T    loc));

extern VB_T *vb_extract_row __((SNMP_PKT_T        *pkt,
                                int                start_indx,
                                int                tcount,
                                OIDC_T            *tlist,
                                int                row_len,
                                struct create_row *row));

extern VB_T *scan_for_leaf_and_match __((SNMP_PKT_T *pkt, 
                                         VB_T       *vbp,
                                         MIBLEAF_T  *leaf,
                                         int         tcount,
                                         OIDC_T     *tlist));

extern VB_T *scan_vb_for_leaf __((SNMP_PKT_T *pktp,
                                  VB_T       *vbp,
                                  MIBLEAF_T  *leaf));

extern VB_T *vb_extract_row_loose __((SNMP_PKT_T *pktp, 
                                      int         indx,
                                      MIBLEAF_T **leaves,
                                      int         tcount,
                                      OIDC_T     *tlist));

extern void group_by_getproc_and_instance __((SNMP_PKT_T *pktp,
                                              VB_T       *first_vbp,
                                              int         tcount,
                                              OIDC_T     *tlist));

extern int oid_to_string __((int        tcount,
                             OIDC_T    *tlist,
                             ALENGTH_T *blen,
                             bits8_t   *buffp,
                             int        iflag));

extern int string_to_oid __((ALENGTH_T  blen,
                             bits8_t   *buffp,
                             int        tcount,
                             OIDC_T    *tlist,
                             int        iflag));

#ifdef __cplusplus
}
#endif

#endif /* auxfuncs_inc */
